package com.example.xiaohei.viewmodel

import androidx.lifecycle.*
import com.example.xiaohei.base.BaseBean
import com.example.xiaohei.bean.Province
import com.example.xiaohei.ui.adapter.MyAdapter
import kotlinx.coroutines.launch
import java.util.function.Function

class CategoryViewModel : ViewModel() {

    var provinces: MutableLiveData<MutableList<Province>> = MutableLiveData()

    val myAdapter = MyAdapter()


    fun getProvinces() {
        //不知道怎么创建空的可变集合，创建之后在清空就很尴尬，一点不优雅
        var list = mutableListOf<BaseBean>(Province("nima",1))
        list.clear()
        for (index in 0..30) {
            var province= Province("我是的$index 个",index)
            list.add(index,province)
        }
        list?.let {
            myAdapter.setNewInstance(it)
        }

    }

}